	<?php
namespace Admin\Controller;
use Think\Controller;
class AdminController extends PublicController{
	 public function index(){
		 $this->display();
	 }

	  //管理员展示
	  public function get_all_admin_list(){
		 $limit = I('get.limit');
		 $page = I('get.page');
		 $like=I('get.like');
		 if(!empty($like)){
			$where["mobile|id"] = array("like","%".$like."%");
		  }
		 $ret['total']=M('admin')->count();
		 $ret['data'] = M('admin')
		  ->where($where)
		  ->page($page,$limit)
		  ->select(); 
		  $ret['code'] = 200;
		  ret($ret);
	  }
	  //管理员添加
	  public function question_insert(){
		  $data['mobile']=I('post.mobile');
		  $data['pwd']=md5(I('post.pwd'));
		  $re=M('admin')->add($data);
		  if($re){
			$ret['isSuccess']=1;
			ret($ret);
		  }else{
			$ret['isSuccess']=0;
			ret($ret);
		  }
	  }
	  //管理员编辑
	  public function question_edit(){
	  	  $data['id']=I('post.id');
	  	  $data['mobile']=I('post.editmobile');
		  $data['pwd']=md5(I('post.editpwd'));
		  $re=M('admin')->where(array('id'=>$data['id']))->save($data);
		  if($re){
			$ret['isSuccess']=1;
			ret($ret);
		  }else{
			$ret['isSuccess']=0;
			ret($ret);
		  }
	  }
	  //管理员删除
	  public function question_del(){
	  	  $data['id']=I('post.id');
		  $re=M('admin')->where(array('id'=>$data['id']))->delete();
		  if($re){
			$ret['isSuccess']=1;
			ret($ret);
		  }else{
			$ret['isSuccess']=0;
			ret($ret);
		  }
	  }

}
